import type { Router } from "vue-router";

/** 路由跳转loadingBar */
export const setupRouterLoadingBar = (router: Router) => {
  router.beforeEach((to, from, next) => {
    window.$loadingBar.start();
    next();
  });

  router.afterEach((to, from) => {
    window.$loadingBar.finish();
  });

  router.onError((err) => {
    window.$message.error(err);
    window.$loadingBar.error();
  });
};
